package br.edu.ufcg.greengrid.model.machine.state;

import br.edu.ufcg.greengrid.model.machine.Machine;

public class GreenMachineState extends AbstractMachineState {

	@Override
	public MSEnum getType() {
		
		return MSEnum.GREEN;
	}

	@Override
	public void changeStateIfNeeded(Machine m) {

		MSEnum newStateType = null;
		long countdown = 0L;

		if(isCountdownZero()){
			newStateType = MSEnum.USER;
			countdown = 0L;
		}
		
		if(newStateType != null){
			m.changeState(newStateType, countdown);
		}
	}
	
	public void wakeUp(Machine m) {
		m.changeState(MSEnum.LEAVING_GREEN, this.countdown);
	}

}
